// JavaScript Document
$(function () {
    // 数据请求
    $('.j_close').click(function(){
    	$('.j_Mask_chao').css('display','none');
		$('#my_tubiao').css('display','none');	
    })
});
function chartonclick(j_chart,data_time,data_point){ //j_chart,my_highchart,data
	$('.j_Mask_chao').css('display','block');
	$('#my_tubiao').css('display','block');
	x_data_point    = data_point.split(',');
	var x_my_data  = [];
	x_data_point.forEach(function(data,index,arr){
		x_my_data.push(+data);
	});
	fetchBigChart(my_highcharts,[data_time.split(','),x_my_data]);
	$('#my_highcharts').css('display','block');
}
function J_tab(id,data){
		return new Highcharts.Chart({
	            chart: {
	            	renderTo: id,
	            	type: "areaspline",
	                spacing: [0, 0, 0, 0]
	            },
	            title: {
	                text: null
	            },
	            colors:['#ffc766'],
	            legend: {
					enabled: false
				},
				credits: {
	                enabled: false
	            },
	            exporting: {
				    enabled:false
				},
	            xAxis: {
	                gridLineWidth: 0,
					tickLength: 0,
					labels: {
						enabled: !1
					},
					title: {
						text: null
					},
					lineWidth: 0,
					tickInterval: 1,
					lineColor: "#cccccc",
					gridLineColor: "#f0f0f0",
					categories:data[0]
	            },
	            tooltip: {
	            	style: {
						color: "white",
						padding: "4px"
					},
					borderWidth: 0,
					shadow: !1,
					backgroundColor: "rgba(34,34,34, 0.6)",
					shared: !0,
					formatter: function() {
						return '<span style="color:' + (this.y >= 0 ? "#00ffa3" : "#ff846b") + '">盈利点位：' + this.y + "</span>"
					}
	            },
	            yAxis: {
					gridLineWidth: 0,
					tickLength: 0,
					labels: {
						enabled: !1
					},
					title: {
						text: null
					},
					tickInterval: 1,
					lineColor: "#cccccc",
					gridLineColor: "#f0f0f0"
				},
	            plotOptions: {
	            	areaspline: {
						fillColor: {
							linearGradient: {
								x1: 0,
								y1: 0,
								x2: 0,
								y2: .8
							},
							stops: [
								[0, "#fcb368"],
		            			[1, Highcharts.Color("#fcb368").setOpacity(0).get('rgba')]
							]
						},
						marker: {
							radius: 0,
							fillColor: "white",
							lineWidth: 0.5,
							lineColor: "#ff8201"
						},
						lineWidth: 0.5,
						states: {
							hover: {
								lineWidth: 0.5
							}
						},
						threshold: null
					},
					series: {
						lineColor: "#ff8201",
						point: {}
					},
	            },
	            series: [{
	                name: '',
	                data: data[1]
	            }]
		})
	}	
	

function fetchBigChart(id,data){
	var t = this;
	// var YAxisValue = ["20170308", "20170309", "20170310", "20170311", "20170312", "20170313", "20170314", "20170315","20170317"]
	// var XAxisValue = [0, 0, 0, 0, 0, 0, 44.97, 109.59, 527.09, 647.57, 705.7, 705.7, 992.24, 1612.35, 1628.8, 2287.35]
	// var data = [["20170308",15],["20170309",15],["20170311",25],["20170312",55],["20170313",15],["20170314",155],["20170315",1],["20170316",15],["20170317",25]]
	// var data = [{time:'20170301',num:'11'},{time:'20170302',num:'22'},{time:'20170303',num:'33'},{time:'20170304',num:'44'},{time:'20170305',num:'44'},{time:'20170306',num:'1111'},{time:'20170307',num:'555'},{time:'20170308',num:'22222'},{time:'20170309',num:'1111'}]
	
	return new Highcharts.Chart({
		chart: {
			renderTo: id,
			type: "areaspline",
			zoomType: "xy"
		},
		title: {
			text: null
		},
		colors: ["#ffc766"],
		legend: {
			enabled: false
		},
		credits: {
            enabled: false
        },
        exporting: {
		    enabled:false
		},
		xAxis: {
			gridLineWidth: 1,
			lineColor: "#cccccc",
			tickColor: "#cccccc",
			gridLineColor: "#f0f0f0",
			categories:data[0],
			tickInterval: Math.ceil(data[0].length / 7)
		},
		yAxis: {
			gridLineWidth: 1,
			lineColor: "#cccccc",
			tickColor: "#cccccc",
			gridLineColor: "#f0f0f0",
			title: {
				text: null
			},
			labels: {
//				formatter: function() {
//					return a.numberFormat(this.value, 0, ".", ",") + " $"
//				}
			}
		},
		tooltip: {
			style: {
				color: "white"
			},
			borderWidth: 0,
			shadow: !1,
			backgroundColor: "rgba(34,34,34, 0.6)",
			shared: !0
		},
		plotOptions: {
			areaspline: {
				fillColor: {
					linearGradient: {
						x1: 0,
						y1: 0,
						x2: 0,
						y2: 1
					},
					stops: [
						[0, "#fcb368"],
		            	[1, Highcharts.Color("#fcb368").setOpacity(0).get('rgba')]
					]
				},
				marker: {
					radius: 0,
					fillColor: "white",
					lineWidth: 1,
					lineColor: "#ffc766"
				},
				lineWidth: 1,
				states: {
					hover: {
						lineWidth: 1
					}
				},
				threshold: null
			},
			series: {
				lineColor: "#ffc766"
			}
		},
		series: [{
			name: "盈利点位",
			data: data[1]
		}]
	})
}
